const {
  GiftShopModel
} = require('../../utils/giftshop-model.js')
const giftShopModel = new GiftShopModel()
Component({
  properties: {
    
  },
  /**
   * 页面的初始数据
   */
  data: {
    keyword: '',
    historySearch: [],
    hotSearch: []
  },
  attached() {
    this.getHotSearch()
  },
  methods: {
    getHotSearch() {
      const merchantId = wx.getStorageSync('merchantId')
      giftShopModel.getHotKeywords({
        merchantId
      }).then(data => {
        console.log(data)
      }).catch(err => {
        wx.showToast({
          title: `${err.error}`,
          icon: 'none'
        })
      })
    },
    inputKeyword(e) {
      const { value } = e.detail
      this.setData({
        keyword: value
      })
    },
    cancel() {
      console.log(this.data.keyword)
      this.setData({
        keyword: ''
      })
      this.triggerEvent('cancel', {})
    }
  }
})